package ipebg.mzk.common.util;

import com.alibaba.fastjson.JSON;

import java.util.List;
import java.util.Map;

/**
 * Created by H2012101 on 2015/12/12.
 */
public class EntityUtil {
    public static <T> T buildEntity(Class<T> cls, Map<String, Object> params) {
        String jsonStr = JSON.toJSONString(params);
        return JSON.parseObject(jsonStr, cls);
    }

    public static <T> List<T> buildEntityList(Class<T> cls, Object object) {
        String jsonStr = JSON.toJSONString(object);
        return JSON.parseArray(jsonStr, cls);
    }

    public static <T> List<T> buildEntityList(Class<T> cls,String jsonStr) {
        return JSON.parseArray(jsonStr, cls);
    }
}
